#include <cstdio>
#include <cstring>
char s[110],stk[110];
int top,n,pos[110];bool mat[110];
int main (){
	scanf("%s",s+1); n = strlen(s+1);
	for(int i = 1;i <= n;i++){
		if(s[i] == '(' || s[i] == '[') stk[++top] = s[i],pos[top] = i;
		if(s[i] == ']'){if(stk[top] == '[') mat[pos[top--]] = 1,mat[i] = 1;}
		if(s[i] == ')'){if(stk[top] == '(') mat[pos[top--]] = 1,mat[i] = 1;}
	}
	for(int i = 1;i <= n;i++) if(mat[i]) putchar(s[i]);else if(s[i] == '(' || s[i] == ')') printf("()");else printf("[]");return 0;
}
